﻿using System;
using EzDesk.Apps.Model.Attendance;
using NUnit.Framework;

namespace EzDesk.Apps.UnitTest.Attendance
{
    // todo: 这个貌似失效了
    public class AttendanceLeaveFixture
    {
        [Test]
        public void TestDuplicateLeave()
        {
            Guid actorId = Guid.NewGuid();
            Guid auditId = Guid.NewGuid();


            var context = new AttendanceServiceContext();

            //var result1 = context.Service.IsDuplicateLeave(DateTime.Parse("2011-3-29 9:00:00"),
            //                                               DateTime.Parse("2011-3-29 18:00:00"), actorId);
            //Assert.AreEqual(result1.Result, false);

            context.Service.ApplyLeave(
                new LeaveInfo()
                    {
                        CreateOn = DateTime.Now,
                        StartTime = DateTime.Parse("2011-3-29 15:00:00"),
                        EndTime = DateTime.Parse("2011-3-29 18:00:00"),
                        UserId = actorId,
                    });
            var result2 = context.Service.IsDuplicateLeave(DateTime.Parse("2011-3-29 9:00:00"),
                                                           DateTime.Parse("2011-3-29 18:00:00"), actorId);
            Assert.AreEqual(result2.Result, true);

            context.Service.ApplyLeave(
                new LeaveInfo()
                {
                    CreateOn = DateTime.Now,
                    StartTime = DateTime.Parse("2011-3-29 9:00:00"),
                    EndTime = DateTime.Parse("2011-3-29 18:00:00"),
                    UserId = actorId,
                });
            var result3 = context.Service.IsDuplicateLeave(DateTime.Parse("2011-3-29 10:00:00"),
                                                           DateTime.Parse("2011-3-29 12:00:00"), actorId);
            Assert.AreEqual(result3.Result, true);

        }
    }
}
